package bank.server.sockets;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

import bank.driver.local.LocalBank;

public class BankServer {
	
	public static void main(String args[]) {
		new BankServer(Integer.parseInt(args[0]));
	}

	public BankServer(int port) {
		LocalBank bank = new LocalBank(); // Used by all handlers
		try {
			ServerSocket server = new ServerSocket(port);
			System.out.println("Startet Bank Server on port " + port);
			while (true) {
				Socket s = server.accept();
				System.out.println("Started new Thread for " + s);
				Thread t = new Thread(new BankHandler(s, bank));
				t.start();
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

}